/**
 * Copyright (c) 2011 eelpo.com
 * All rights reserved.
 */
package com.eelpo.cmmp.core.wicket.panel.grid.column;

import java.util.Date;

import com.eelpo.common.util.DateFormatUtils;

import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.IModel;
import org.apache.wicket.util.lang.PropertyResolver;

/**
 * <pre>
 * 
 * 时间属性列
 * 
 * </pre>
 * 
 * @author <a href="mailto:Brian@eelpo.com">汪洪州</a>
 * @since 1.0
 */
public class TimePropertyColumn<T> extends PropertyColumn<T> {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = -4622909736639468263L;

	/**
	 * @param header
	 * @param property
	 * @param isAllowSort
	 * @param location
	 */
	public TimePropertyColumn(String header, String property, boolean isAllowSort, ColumnLocation location) {
		super(header, property, isAllowSort, location);
	}

	/**
	 * @param header
	 * @param property
	 * @param location
	 */
	public TimePropertyColumn(String header, String property, ColumnLocation location) {
		super(header, property, location);
	}

	/**
	 * @param header
	 * @param property
	 * @param sort
	 * @param isAllowSort
	 * @param location
	 */
	public TimePropertyColumn(String header, String property, String sort, boolean isAllowSort, ColumnLocation location) {
		super(header, property, sort, isAllowSort, location);
	}

	@Override
	public void populateItem(Item<ICellPopulator<T>> cellItem, String componentId, IModel<T> rowModel) {
		cellItem.add(new Label(componentId, DateFormatUtils.formatDateTime((Date) PropertyResolver.getValue(property, rowModel.getObject()))));
	}
}
